Skip to content

Apply calico-node before Typha during upgrades to prevent cluster-wide NotReady - #5110

Open
AdheipSingh wants to merge 3 commits into
tigera:masterfrom
deep-bi:fix/typha-node-upgrade-ordering
Open

Apply calico-node before Typha during upgrades to prevent cluster-wide NotReady#5110
AdheipSingh wants to merge 3 commits into
tigera:masterfrom
deep-bi:fix/typha-node-upgrade-ordering

Conversation

@AdheipSingh

@AdheipSingh AdheipSingh commented Jul 27, 2026

Copy link
Copy Markdown

Description

Type of change: bug fix

Problem: During upgrades, the operator applies the Typha Deployment and the calico-node DaemonSet in the same reconcile, so both roll simultaneously. Typha (typically 3 replicas) finishes its rollout in about a minute, while calico-node on a large cluster takes much longer. Felix is compatible with an older Typha, but an older Felix cannot sync with a newer Typha — so once all Typha replicas are on the new version, every still-old calico-node pod loses sync, fails its readiness probe after ~90s (3 × 30s), and goes NotReady. The DaemonSet controller does not count already-unavailable pods against maxUnavailable/maxSurge, so it then replaces pods across the whole cluster at once instead of honoring the configured rolling-update limits. On a ~200 node production cluster this presented as a cluster-wide wave of NotReady calico-node pods during a 3.31 → 3.32 upgrade.

Fix:

  • Apply the calico-node component before the remaining components.
  • After applying, read the calico-node DaemonSet directly from the API server rather than the cached client — immediately after the write, the informer cache can still hold the pre-update object whose status reports the previous rollout as complete, which would open the gate prematurely (this race was observed in testing: identical code passed or failed depending on whether the watch event beat the read).
  • Gate the Typha component on the calico-node rollout being complete (ObservedGeneration >= Generation, all pods updated and ready) using the existing component Ready() mechanism.

With this ordering, new calico-node pods connect to old Typha (the compatible direction) while rolling under the configured limits, and Typha updates last, when every Felix is already on the new version. First installs are unaffected (no DaemonSet exists, so the gate is open), and in steady state the check passes immediately because the DaemonSet generation is unchanged.

Testing: Validated on a 30-node cluster upgrading Calico v3.31.3 → v3.32.1:

  • With nodeUpdateStrategy: {maxSurge: 4, maxUnavailable: 0} (the affected user's configuration): calico-node Ready stayed 30/30 for the entire upgrade across every DaemonSet status transition; peak 34 concurrent pods (30 + exactly 4 surge), no limit bypass; node phase ~4 minutes; Typha updated only after all 30 nodes completed.
  • With the default strategy (maxUnavailable: 1): Ready never dropped below 29/30 (the single pod being replaced), Typha gated for the full ~18 minute rollout and updated within seconds of the last node becoming ready.
  • Without this change, the same upgrade dropped Ready to 11/30, with the DaemonSet controller replacing ~12 pods within 2 seconds.

Affected components: installation controller (core_controller.go), Typha render component.

Release Note

During upgrades, the operator now waits for the calico-node DaemonSet rollout to complete before updating Typha, preventing cluster-wide calico-node readiness disruption caused by older Felix being unable to sync with newer Typha.

For PR author

  • Tests for change.
  • If changing pkg/apis/, run make gen-files
  • If changing versions, run make gen-versions

For PR reviewers

A note for code reviewers - all pull requests must have the following:

  • Milestone set according to targeted release.
  • Appropriate labels:
    • kind/bug if this is a bugfix.
    • kind/enhancement if this is a a new feature.
    • enterprise if this PR applies to Calico Enterprise only.

During upgrades, applying Typha and calico-node in the same reconcile
rolls both simultaneously. Felix may be newer than Typha but not older,
so once Typha completes its rollout first, still-old calico-node pods
can no longer sync, go NotReady after their readiness probe window, and
the DaemonSet controller stops honoring surge limits and replaces pods
cluster-wide.

Apply calico-node first, then gate Typha on the DaemonSet being fully
rolled out. Read the DaemonSet directly from the API server since the
informer cache may still hold the pre-update object immediately after
the write.
@CLAassistant

CLAassistant commented Jul 27, 2026

Copy link
Copy Markdown

CLA assistant check
All committers have signed the CLA.

@caseydavenport

Copy link
Copy Markdown
Member

@AdheipSingh thanks for the PR - was there a specific issue you noticed that prompted this?

We try to make the upgrade not depend on ordering regardless, so curious if we introduced an unexpected dependency in v3.32.

Comment thread pkg/controller/installation/core_controller.go Outdated
Comment thread pkg/controller/installation/core_controller.go Outdated
Comment thread pkg/controller/installation/core_controller.go Outdated
Comment thread pkg/controller/installation/core_controller.go Outdated
Comment thread pkg/controller/installation/core_controller.go Outdated
Comment thread pkg/render/typha.go Outdated
return reconcile.Result{}, err
}

// Apply calico-node before the remaining components so that its rollout

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This ordering is inverted for downgrades, where node rolls to the older Felix first while Typha is still new, which is exactly the direction the comment says doesn't work.

Wonder if we need more awareness on if this is an upgrade / downgrade / or simply a configuration change.

Copy link
Copy Markdown
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Correct — as written, the deferral applies to any image change, so a downgrade would also roll node first, which is the direction the skew policy doesn't support. Might consider detecting direction by comparing the resolved desired version against the deployed one and only deferring for upgrades (falling back to current behavior for downgrades and unparseable references like digests), but didn't want to add version-parsing machinery without your input. Would you prefer that in this PR, as a follow-up, or is there an existing pattern in the operator for knowing upgrade vs downgrade that we should use?

Comment thread pkg/controller/installation/core_controller.go Outdated
@caseydavenport

Copy link
Copy Markdown
Member

/sem-approve

@AdheipSingh

AdheipSingh commented Aug 3, 2026

Copy link
Copy Markdown
Author

Problem: During upgrades, the operator applies the Typha Deployment and the calico-node DaemonSet in the same reconcile, so both roll simultaneously. Typha (typically 3 replicas) finishes its rollout in about a minute, while calico-node on a large cluster takes much longer. Felix is compatible with an older Typha, but an older Felix cannot sync with a newer Typha — so once all Typha replicas are on the new version, every still-old calico-node pod loses sync, fails its readiness probe after ~90s (3 × 30s), and goes NotReady. The DaemonSet controller does not count already-unavailable pods against maxUnavailable/maxSurge, so it then replaces pods across the whole cluster at once instead of honoring the configured rolling-update limits. On a ~200 node production cluster this presented as a cluster-wide wave of NotReady calico-node pods during a 3.31 → 3.32 upgrade.

Hi @caseydavenport , thanks for the review this is main reason ˆˆ for this PR. We have large nodes ( 1000 + ), and when we increase maxSurge to speed up rollouts, keeping maxUnavailable as 0, we see a large disruption. This was the reason for fixing this. We saw no issue when maxSurge is set to 1, as we increase surge we see this issue. Also this is visible when we tried to upgrade 30 nodes with maxSurge 4, maxSurge 1/2 works fine on 30 nodes.....so the disruption is proportional to no of nodes and maxSurge count.

A newer Felix can talk to an older Typha just fine. But an older Felix cannot talk to a newer Typha.... the connection just dies. So during any upgrade there's exactly one safe order: upgrade all the calico-nodes first, Typha last. Then every mixed pairing that ever exists during the transition is "newer Felix --> older Typha," the direction that works.

The operator ignored that order. When you upgrade Calico, the tigera-operator updates Typha and calico-node in the same breath. Typha is only 3 pods it finishes upgrading in about a minute. calico-node on 200 nodes, at 4 at a time, takes half an hour. So one minute into the upgrade you have: 3 brand-new Typhas, and ~196 still-old calico-nodes — every one of them now in the forbidden pairing. They all lose their instruction feed simultaneously, all fail their health checks 90 seconds later, and all flip to NotReady at once.

@AdheipSingh

Copy link
Copy Markdown
Author

Unit test is generated via Claude.

@caseydavenport

Copy link
Copy Markdown
Member

But an older Felix cannot talk to a newer Typha.... the connection just dies.

This is the part that I'm worried about - do you have log output by chance from when this happened? We try to avoid this!

@caseydavenport

Copy link
Copy Markdown
Member

/sem-approve

@AdheipSingh

Copy link
Copy Markdown
Author

But an older Felix cannot talk to a newer Typha.... the connection just dies.

This is the part that I'm worried about - do you have log output by chance from when this happened? We try to avoid this!

Let me share with you RCA document.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

4 participants